//
//  HHCommon.m
//  zhjt
//
//  Created by xthuang_293 on 14/12/7.
//  Copyright (c) 2014年 sristc. All rights reserved.
//

#import "RSCallPhone.h"

#pragma mark - 日志开关
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif

@implementation RSCallPhone
+(BOOL)dialTo:(NSString *)_mobile inView:(UIView *)_parentView
{
    if (!_parentView) {
        return NO;
    }
    if (_mobile.length == 0) {
        DLog(@"拨打号码为空");
        return NO;
    }
    BOOL isDeviceCanTel = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]];
    if (isDeviceCanTel) {
        NSURL *dialUrl = [NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",_mobile]];
        UIWebView * callWebview = [[UIWebView alloc] init];
        [callWebview loadRequest:[NSURLRequest requestWithURL:dialUrl]];
        [_parentView addSubview:callWebview];
        callWebview = nil;
        return YES;
    } else {
        DLog(@"您的设备不支持通话功能");
        return NO;
    }
}
@end
